#!/usr/bin/env bash

#########################################################################
# Title:         Download Torrent Data From An Rclone Remote            #
# Author(s):     l3uddz                                                 #
# URL:           https://github.com/cloudbox/cloudbox                   #
# Description:   Downloads torrents that were backed up via             #
#                sync_torrents_to_rclone_remote.sh                      #
# --                                                                    #
#         Part of the Cloudbox project: https://cloudbox.works          #
#########################################################################
#                   GNU General Public License v3.0                     #
#########################################################################

if ! /usr/bin/screen -list | /bin/grep -q "torrents_download"; then

	/bin/rm -rfv /opt/scripts/rclone/download_torrents_from_rclone_remote.log

	/usr/bin/screen -dmS torrents_download /usr/bin/rclone copy \
		--user-agent='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36' \
		--config=/home/{{ user.name }}/.config/rclone/rclone.conf \
		--verbose=1 \
		--transfers=8 \
		--stats=60s \
		--checkers=16 \
		--drive-chunk-size=128M \
		--fast-list \
		--log-file=/opt/scripts/rclone/download_torrents_from_rclone_remote.log \
		{{ rclone.remote }}:/downloads/torrents {{ downloads.torrents }}

fi
